home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gas_251.zip / bin_251 / binutils / sysinfo.c < prev    next >
C/C++ Source or Header  |  1994-10-22  |  30KB  |  1,229 lines

  1.  
  2. /*  A Bison parser, made from ./sysinfo.y with Bison version GNU Bison version 1.22
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    COND    258
  8. #define    REPEAT    259
  9. #define    TYPE    260
  10. #define    NAME    261
  11. #define    NUMBER    262
  12. #define    UNIT    263
  13.  
  14. #line 1 "./sysinfo.y"
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18.  
  19. extern char *word;
  20. extern char writecode;
  21. extern int number;
  22. extern int unit;
  23. char nice_name[1000];
  24. char *it;
  25. int sofar;
  26. int width;
  27. int code;
  28. char * repeat;
  29. char *oldrepeat;
  30. char *name;
  31. int rdepth;
  32. char *loop [] = {"","n","m","/*BAD*/"};
  33. char *names[] = {" ","[n]","[n][m]"};
  34. char *pnames[]= {"","*","**"};
  35.  
  36. #line 24 "./sysinfo.y"
  37. typedef union {
  38.  int i;
  39.  char *s;
  40. } YYSTYPE;
  41.  
  42. #ifndef YYLTYPE
  43. typedef
  44.   struct yyltype
  45.     {
  46.       int timestamp;
  47.       int first_line;
  48.       int first_column;
  49.       int last_line;
  50.       int last_column;
  51.       char *text;
  52.    }
  53.   yyltype;
  54.  
  55. #define YYLTYPE yyltype
  56. #endif
  57.  
  58. #ifndef YYDEBUG
  59. #define YYDEBUG 1
  60. #endif
  61.  
  62. #include <stdio.h>
  63.  
  64. #ifndef __cplusplus
  65. #ifndef __STDC__
  66. #define const
  67. #endif
  68. #endif
  69.  
  70.  
  71.  
  72. #define    YYFINAL        55
  73. #define    YYFLAG        -32768
  74. #define    YYNTBASE    13
  75.  
  76. #define YYTRANSLATE(x) ((unsigned)(x) <= 263 ? yytranslate[x] : 31)
  77.  
  78. static const char yytranslate[] = {     0,
  79.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  80.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  81.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  82.      2,     2,     2,     2,     2,     2,     2,     2,     2,     5,
  83.      6,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  84.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  85.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  86.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  87.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  88.      7,     2,     8,     2,     2,     2,     2,     2,     2,     2,
  89.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  90.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  91.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  92.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  93.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  94.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  95.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  96.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  97.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  98.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  99.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  100.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  101.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  102.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  103.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  104.      2,     2,     2,     2,     2,     1,     2,     3,     4,     9,
  105.     10,    11,    12
  106. };
  107.  
  108. #if YYDEBUG != 0
  109. static const short yyprhs[] = {     0,
  110.      0,     1,     4,     7,     8,     9,    16,    19,    22,    25,
  111.     26,    27,    34,    35,    42,    43,    54,    56,    57,    61,
  112.     64,    68,    69,    70,    74,    75,    81
  113. };
  114.  
  115. static const short yyrhs[] = {    -1,
  116.     14,    15,     0,    16,    15,     0,     0,     0,     5,    10,
  117.     11,    17,    18,     6,     0,    23,    18,     0,    21,    18,
  118.      0,    19,    18,     0,     0,     0,     5,     4,    10,    20,
  119.     18,     6,     0,     0,     5,     3,    10,    22,    18,     6,
  120.      0,     0,     5,    26,     5,    25,    27,     6,    28,    24,
  121.     29,     6,     0,     9,     0,     0,     5,    10,     6,     0,
  122.     11,    12,     0,     5,    10,     6,     0,     0,     0,     5,
  123.     30,     6,     0,     0,    30,     5,    10,    10,     6,     0,
  124.     10,     0
  125. };
  126.  
  127. #endif
  128.  
  129. #if YYDEBUG != 0
  130. static const short yyrline[] = { 0,
  131.     38,    59,    75,    76,    79,   130,   150,   152,   153,   154,
  132.    157,   186,   204,   217,   230,   233,   338,   340,   343,   348,
  133.    354,   356,   359,   360,   362,   363,   380
  134. };
  135.  
  136. static const char * const yytname[] = {   "$","error","$illegal.","COND","REPEAT",
  137. "'('","')'","'['","']'","TYPE","NAME","NUMBER","UNIT","top","@1","it_list","it",
  138. "@2","it_field_list","repeat_it_field","@3","cond_it_field","@4","it_field",
  139. "@5","attr_type","attr_desc","attr_size","attr_id","enums","enum_list",""
  140. };
  141. #endif
  142.  
  143. static const short yyr1[] = {     0,
  144.     14,    13,    15,    15,    17,    16,    18,    18,    18,    18,
  145.     20,    19,    22,    21,    24,    23,    25,    25,    26,    27,
  146.     28,    28,    29,    29,    30,    30,    -1
  147. };
  148.  
  149. static const short yyr2[] = {     0,
  150.      0,     2,     2,     0,     0,     6,     2,     2,     2,     0,
  151.      0,     6,     0,     6,     0,    10,     1,     0,     3,     2,
  152.      3,     0,     0,     3,     0,     5,     1
  153. };
  154.  
  155. static const short yydefact[] = {     1,
  156.      4,     0,     2,     4,     0,     3,     5,    10,     0,     0,
  157.     10,    10,    10,     0,     0,     0,     0,     6,     9,     8,
  158.      7,    13,    11,     0,    18,    10,    10,    19,    17,     0,
  159.      0,     0,     0,     0,    14,    12,    20,    22,     0,    15,
  160.      0,    23,    21,    25,     0,     0,    16,     0,    24,     0,
  161.      0,    26,     0,     0,     0
  162. };
  163.  
  164. static const short yydefgoto[] = {    53,
  165.      1,     3,     4,     8,    10,    11,    27,    12,    26,    13,
  166.     42,    30,    17,    34,    40,    45,    46
  167. };
  168.  
  169. static const short yypact[] = {-32768,
  170.      3,    -1,-32768,     3,     2,-32768,-32768,     5,     0,     6,
  171.      5,     5,     5,     4,     7,     8,    14,-32768,-32768,-32768,
  172. -32768,-32768,-32768,    15,    11,     5,     5,-32768,-32768,    12,
  173.     16,    18,    13,    20,-32768,-32768,-32768,    22,    19,-32768,
  174.     24,    23,-32768,-32768,    25,     1,-32768,    26,-32768,    27,
  175.     28,-32768,    32,    33,-32768
  176. };
  177.  
  178. static const short yypgoto[] = {-32768,
  179. -32768,    31,-32768,-32768,   -11,-32768,-32768,-32768,-32768,-32768,
  180. -32768,-32768,-32768,-32768,-32768,-32768,-32768
  181. };
  182.  
  183.  
  184. #define    YYLAST        37
  185.  
  186.  
  187. static const short yytable[] = {    19,
  188.     20,    21,    14,    15,    16,    48,    49,     2,     5,     9,
  189.      0,    18,     7,    22,    31,    32,    23,    24,    25,    29,
  190.     28,    35,    33,    36,    37,    38,    39,    44,    41,    43,
  191.     47,    54,    55,    52,     6,    50,    51
  192. };
  193.  
  194. static const short yycheck[] = {    11,
  195.     12,    13,     3,     4,     5,     5,     6,     5,    10,     5,
  196.     -1,     6,    11,    10,    26,    27,    10,    10,     5,     9,
  197.      6,     6,    11,     6,    12,     6,     5,     5,    10,     6,
  198.      6,     0,     0,     6,     4,    10,    10
  199. };
  200. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  201. #line 3 "/usr/unsupported/lib/bison.simple"
  202.  
  203. /* Skeleton output parser for bison,
  204.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  205.  
  206.    This program is free software; you can redistribute it and/or modify
  207.    it under the terms of the GNU General Public License as published by
  208.    the Free Software Foundation; either version 1, or (at your option)
  209.    any later version.
  210.  
  211.    This program is distributed in the hope that it will be useful,
  212.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  213.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  214.    GNU General Public License for more details.
  215.  
  216.    You should have received a copy of the GNU General Public License
  217.    along with this program; if not, write to the Free Software
  218.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  219.  
  220.  
  221. #ifndef alloca
  222. #ifdef __GNUC__
  223. #define alloca __builtin_alloca
  224. #else /* not GNU C.  */
  225. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  226. #include <alloca.h>
  227. #else /* not sparc */
  228. #if defined (MSDOS) && !defined (__TURBOC__)
  229. #include <malloc.h>
  230. #else /* not MSDOS, or __TURBOC__ */
  231. #if defined(_AIX)
  232. #include <malloc.h>
  233.  #pragma alloca
  234. #else /* not MSDOS, __TURBOC__, or _AIX */
  235. #ifdef __hpux
  236. #ifdef __cplusplus
  237. extern "C" {
  238. void *alloca (unsigned int);
  239. };
  240. #else /* not __cplusplus */
  241. void *alloca ();
  242. #endif /* not __cplusplus */
  243. #endif /* __hpux */
  244. #endif /* not _AIX */
  245. #endif /* not MSDOS, or __TURBOC__ */
  246. #endif /* not sparc.  */
  247. #endif /* not GNU C.  */
  248. #endif /* alloca not defined.  */
  249.  
  250. /* This is the parser code that is written into each bison parser
  251.   when the %semantic_parser declaration is not specified in the grammar.
  252.   It was written by Richard Stallman by simplifying the hairy parser
  253.   used when %semantic_parser is specified.  */
  254.  
  255. /* Note: there must be only one dollar sign in this file.
  256.    It is replaced by the list of actions, each action
  257.    as one case of the switch.  */
  258.  
  259. #define yyerrok        (yyerrstatus = 0)
  260. #define yyclearin    (yychar = YYEMPTY)
  261. #define YYEMPTY        -2
  262. #define YYEOF        0
  263. #define YYACCEPT    return(0)
  264. #define YYABORT     return(1)
  265. #define YYERROR        goto yyerrlab1
  266. /* Like YYERROR except do call yyerror.
  267.    This remains here temporarily to ease the
  268.    transition to the new meaning of YYERROR, for GCC.
  269.    Once GCC version 2 has supplanted version 1, this can go.  */
  270. #define YYFAIL        goto yyerrlab
  271. #define YYRECOVERING()  (!!yyerrstatus)
  272. #define YYBACKUP(token, value) \
  273. do                                \
  274.   if (yychar == YYEMPTY && yylen == 1)                \
  275.     { yychar = (token), yylval = (value);            \
  276.       yychar1 = YYTRANSLATE (yychar);                \
  277.       YYPOPSTACK;                        \
  278.       goto yybackup;                        \
  279.     }                                \
  280.   else                                \
  281.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  282. while (0)
  283.  
  284. #define YYTERROR    1
  285. #define YYERRCODE    256
  286.  
  287. #ifndef YYPURE
  288. #define YYLEX        yylex()
  289. #endif
  290.  
  291. #ifdef YYPURE
  292. #ifdef YYLSP_NEEDED
  293. #define YYLEX        yylex(&yylval, &yylloc)
  294. #else
  295. #define YYLEX        yylex(&yylval)
  296. #endif
  297. #endif
  298.  
  299. /* If nonreentrant, generate the variables here */
  300.  
  301. #ifndef YYPURE
  302.  
  303. int    yychar;            /*  the lookahead symbol        */
  304. YYSTYPE    yylval;            /*  the semantic value of the        */
  305.                 /*  lookahead symbol            */
  306.  
  307. #ifdef YYLSP_NEEDED
  308. YYLTYPE yylloc;            /*  location data for the lookahead    */
  309.                 /*  symbol                */
  310. #endif
  311.  
  312. int yynerrs;            /*  number of parse errors so far       */
  313. #endif  /* not YYPURE */
  314.  
  315. #if YYDEBUG != 0
  316. int yydebug;            /*  nonzero means print parse trace    */
  317. /* Since this is uninitialized, it does not stop multiple parsers
  318.    from coexisting.  */
  319. #endif
  320.  
  321. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  322.  
  323. #ifndef    YYINITDEPTH
  324. #define YYINITDEPTH 200
  325. #endif
  326.  
  327. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  328.     (effective only if the built-in stack extension method is used).  */
  329.  
  330. #if YYMAXDEPTH == 0
  331. #undef YYMAXDEPTH
  332. #endif
  333.  
  334. #ifndef YYMAXDEPTH
  335. #define YYMAXDEPTH 10000
  336. #endif
  337.  
  338. /* Prevent warning if -Wstrict-prototypes.  */
  339. #ifdef __GNUC__
  340. int yyparse (void);
  341. #endif
  342.  
  343. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  344. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  345. #else                /* not GNU C or C++ */
  346. #ifndef __cplusplus
  347.  
  348. /* This is the most reliable way to avoid incompatibilities
  349.    in available built-in functions on various systems.  */
  350. static void
  351. __yy_bcopy (from, to, count)
  352.      char *from;
  353.      char *to;
  354.      int count;
  355. {
  356.   register char *f = from;
  357.   register char *t = to;
  358.   register int i = count;
  359.  
  360.   while (i-- > 0)
  361.     *t++ = *f++;
  362. }
  363.  
  364. #else /* __cplusplus */
  365.  
  366. /* This is the most reliable way to avoid incompatibilities
  367.    in available built-in functions on various systems.  */
  368. static void
  369. __yy_bcopy (char *from, char *to, int count)
  370. {
  371.   register char *f = from;
  372.   register char *t = to;
  373.   register int i = count;
  374.  
  375.   while (i-- > 0)
  376.     *t++ = *f++;
  377. }
  378.  
  379. #endif
  380. #endif
  381.  
  382. #line 184 "/usr/unsupported/lib/bison.simple"
  383. int
  384. yyparse()
  385. {
  386.   register int yystate;
  387.   register int yyn;
  388.   register short *yyssp;
  389.   register YYSTYPE *yyvsp;
  390.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  391.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  392.  
  393.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  394.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  395.  
  396.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  397.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  398.  
  399. #ifdef YYLSP_NEEDED
  400.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  401.   YYLTYPE *yyls = yylsa;
  402.   YYLTYPE *yylsp;
  403.  
  404. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  405. #else
  406. #define YYPOPSTACK   (yyvsp--, yyssp--)
  407. #endif
  408.  
  409.   int yystacksize = YYINITDEPTH;
  410.  
  411. #ifdef YYPURE
  412.   int yychar;
  413.   YYSTYPE yylval;
  414.   int yynerrs;
  415. #ifdef YYLSP_NEEDED
  416.   YYLTYPE yylloc;
  417. #endif
  418. #endif
  419.  
  420.   YYSTYPE yyval;        /*  the variable used to return        */
  421.                 /*  semantic values from the action    */
  422.                 /*  routines                */
  423.  
  424.   int yylen;
  425.  
  426. #if YYDEBUG != 0
  427.   if (yydebug)
  428.     fprintf(stderr, "Starting parse\n");
  429. #endif
  430.  
  431.   yystate = 0;
  432.   yyerrstatus = 0;
  433.   yynerrs = 0;
  434.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  435.  
  436.   /* Initialize stack pointers.
  437.      Waste one element of value and location stack
  438.      so that they stay on the same level as the state stack.
  439.      The wasted elements are never initialized.  */
  440.  
  441.   yyssp = yyss - 1;
  442.   yyvsp = yyvs;
  443. #ifdef YYLSP_NEEDED
  444.   yylsp = yyls;
  445. #endif
  446.  
  447. /* Push a new state, which is found in  yystate  .  */
  448. /* In all cases, when you get here, the value and location stacks
  449.    have just been pushed. so pushing a state here evens the stacks.  */
  450. yynewstate:
  451.  
  452.   *++yyssp = yystate;
  453.  
  454.   if (yyssp >= yyss + yystacksize - 1)
  455.     {
  456.       /* Give user a chance to reallocate the stack */
  457.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  458.       YYSTYPE *yyvs1 = yyvs;
  459.       short *yyss1 = yyss;
  460. #ifdef YYLSP_NEEDED
  461.       YYLTYPE *yyls1 = yyls;
  462. #endif
  463.  
  464.       /* Get the current used size of the three stacks, in elements.  */
  465.       int size = yyssp - yyss + 1;
  466.  
  467. #ifdef yyoverflow
  468.       /* Each stack pointer address is followed by the size of
  469.      the data in use in that stack, in bytes.  */
  470. #ifdef YYLSP_NEEDED
  471.       /* This used to be a conditional around just the two extra args,
  472.      but that might be undefined if yyoverflow is a macro.  */
  473.       yyoverflow("parser stack overflow",
  474.          &yyss1, size * sizeof (*yyssp),
  475.          &yyvs1, size * sizeof (*yyvsp),
  476.          &yyls1, size * sizeof (*yylsp),
  477.          &yystacksize);
  478. #else
  479.       yyoverflow("parser stack overflow",
  480.          &yyss1, size * sizeof (*yyssp),
  481.          &yyvs1, size * sizeof (*yyvsp),
  482.          &yystacksize);
  483. #endif
  484.  
  485.       yyss = yyss1; yyvs = yyvs1;
  486. #ifdef YYLSP_NEEDED
  487.       yyls = yyls1;
  488. #endif
  489. #else /* no yyoverflow */
  490.       /* Extend the stack our own way.  */
  491.       if (yystacksize >= YYMAXDEPTH)
  492.     {
  493.       yyerror("parser stack overflow");
  494.       return 2;
  495.     }
  496.       yystacksize *= 2;
  497.       if (yystacksize > YYMAXDEPTH)
  498.     yystacksize = YYMAXDEPTH;
  499.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  500.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  501.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  502.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  503. #ifdef YYLSP_NEEDED
  504.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  505.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  506. #endif
  507. #endif /* no yyoverflow */
  508.  
  509.       yyssp = yyss + size - 1;
  510.       yyvsp = yyvs + size - 1;
  511. #ifdef YYLSP_NEEDED
  512.       yylsp = yyls + size - 1;
  513. #endif
  514.  
  515. #if YYDEBUG != 0
  516.       if (yydebug)
  517.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  518. #endif
  519.  
  520.       if (yyssp >= yyss + yystacksize - 1)
  521.     YYABORT;
  522.     }
  523.  
  524. #if YYDEBUG != 0
  525.   if (yydebug)
  526.     fprintf(stderr, "Entering state %d\n", yystate);
  527. #endif
  528.  
  529.   goto yybackup;
  530.  yybackup:
  531.  
  532. /* Do appropriate processing given the current state.  */
  533. /* Read a lookahead token if we need one and don't already have one.  */
  534. /* yyresume: */
  535.  
  536.   /* First try to decide what to do without reference to lookahead token.  */
  537.  
  538.   yyn = yypact[yystate];
  539.   if (yyn == YYFLAG)
  540.     goto yydefault;
  541.  
  542.   /* Not known => get a lookahead token if don't already have one.  */
  543.  
  544.   /* yychar is either YYEMPTY or YYEOF
  545.      or a valid token in external form.  */
  546.  
  547.   if (yychar == YYEMPTY)
  548.     {
  549. #if YYDEBUG != 0
  550.       if (yydebug)
  551.     fprintf(stderr, "Reading a token: ");
  552. #endif
  553.       yychar = YYLEX;
  554.     }
  555.  
  556.   /* Convert token to internal form (in yychar1) for indexing tables with */
  557.  
  558.   if (yychar <= 0)        /* This means end of input. */
  559.     {
  560.       yychar1 = 0;
  561.       yychar = YYEOF;        /* Don't call YYLEX any more */
  562.  
  563. #if YYDEBUG != 0
  564.       if (yydebug)
  565.     fprintf(stderr, "Now at end of input.\n");
  566. #endif
  567.     }
  568.   else
  569.     {
  570.       yychar1 = YYTRANSLATE(yychar);
  571.  
  572. #if YYDEBUG != 0
  573.       if (yydebug)
  574.     {
  575.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  576.       /* Give the individual parser a way to print the precise meaning
  577.          of a token, for further debugging info.  */
  578. #ifdef YYPRINT
  579.       YYPRINT (stderr, yychar, yylval);
  580. #endif
  581.       fprintf (stderr, ")\n");
  582.     }
  583. #endif
  584.     }
  585.  
  586.   yyn += yychar1;
  587.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  588.     goto yydefault;
  589.  
  590.   yyn = yytable[yyn];
  591.  
  592.   /* yyn is what to do for this token type in this state.
  593.      Negative => reduce, -yyn is rule number.
  594.      Positive => shift, yyn is new state.
  595.        New state is final state => don't bother to shift,
  596.        just return success.
  597.      0, or most negative number => error.  */
  598.  
  599.   if (yyn < 0)
  600.     {
  601.       if (yyn == YYFLAG)
  602.     goto yyerrlab;
  603.       yyn = -yyn;
  604.       goto yyreduce;
  605.     }
  606.   else if (yyn == 0)
  607.     goto yyerrlab;
  608.  
  609.   if (yyn == YYFINAL)
  610.     YYACCEPT;
  611.  
  612.   /* Shift the lookahead token.  */
  613.  
  614. #if YYDEBUG != 0
  615.   if (yydebug)
  616.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  617. #endif
  618.  
  619.   /* Discard the token being shifted unless it is eof.  */
  620.   if (yychar != YYEOF)
  621.     yychar = YYEMPTY;
  622.  
  623.   *++yyvsp = yylval;
  624. #ifdef YYLSP_NEEDED
  625.   *++yylsp = yylloc;
  626. #endif
  627.  
  628.   /* count tokens shifted since error; after three, turn off error status.  */
  629.   if (yyerrstatus) yyerrstatus--;
  630.  
  631.   yystate = yyn;
  632.   goto yynewstate;
  633.  
  634. /* Do the default action for the current state.  */
  635. yydefault:
  636.  
  637.   yyn = yydefact[yystate];
  638.   if (yyn == 0)
  639.     goto yyerrlab;
  640.  
  641. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  642. yyreduce:
  643.   yylen = yyr2[yyn];
  644.   if (yylen > 0)
  645.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  646.  
  647. #if YYDEBUG != 0
  648.   if (yydebug)
  649.     {
  650.       int i;
  651.  
  652.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  653.            yyn, yyrline[yyn]);
  654.  
  655.       /* Print the symbols being reduced, and their result.  */
  656.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  657.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  658.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  659.     }
  660. #endif
  661.  
  662.  
  663.   switch (yyn) {
  664.  
  665. case 1:
  666. #line 38 "./sysinfo.y"
  667. {
  668.   switch (writecode)
  669.     {
  670.     case 'i':
  671.       printf("#ifdef SYSROFF_SWAP_IN\n");
  672.       break; 
  673.     case 'p':
  674.       printf("#ifdef SYSROFF_p\n");
  675.       break; 
  676.     case 'd':
  677.       break;
  678.     case 'g':
  679.       printf("#ifdef SYSROFF_SWAP_OUT\n");
  680.       break;
  681.     case 'c':
  682.       printf("#ifdef SYSROFF_PRINT\n");
  683.       printf("#include <stdio.h>\n");
  684.       printf("#include <stdlib.h>\n");
  685.       break;
  686.     }
  687.  ;
  688.     break;}
  689. case 2:
  690. #line 59 "./sysinfo.y"
  691. {
  692.   switch (writecode) {
  693.   case 'i':
  694.   case 'p':
  695.   case 'g':
  696.   case 'c':
  697.     printf("#endif\n");
  698.     break; 
  699.   case 'd':
  700.     break;
  701.   }
  702. ;
  703.     break;}
  704. case 5:
  705. #line 81 "./sysinfo.y"
  706. {
  707.     it = yyvsp[-1].s; code = yyvsp[0].i;
  708.     switch (writecode) 
  709.       {
  710.       case 'd':
  711.         printf("\n\n\n#define IT_%s_CODE 0x%x\n", it,code);
  712.         printf("struct IT_%s { \n", it);
  713.         break;
  714.       case 'i':
  715.         printf("void sysroff_swap_%s_in(ptr)\n",yyvsp[-1].s);
  716.         printf("struct IT_%s *ptr;\n", it);
  717.         printf("{\n");
  718.         printf("char raw[255];\n");
  719.         printf("\tint idx = 0 ;\n");
  720.         printf("\tint size;\n");
  721.         printf("memset(raw,0,255);\n");    
  722.         printf("memset(ptr,0,sizeof(*ptr));\n");
  723.         printf("size = fillup(raw);\n");
  724.         break;
  725.       case 'g':
  726.         printf("void sysroff_swap_%s_out(file,ptr)\n",yyvsp[-1].s);
  727.         printf("FILE * file;\n");
  728.         printf("struct IT_%s *ptr;\n", it);
  729.         printf("{\n");
  730.         printf("\tchar raw[255];\n");
  731.         printf("\tint idx = 16 ;\n");
  732.         printf("\tmemset (raw, 0, 255);\n");
  733.         printf("\tcode = IT_%s_CODE;\n", it);
  734.         break;
  735.       case 'o':
  736.         printf("void sysroff_swap_%s_out(abfd,ptr)\n",yyvsp[-1].s);
  737.         printf("bfd * abfd;\n");
  738.         printf("struct IT_%s *ptr;\n",it);
  739.         printf("{\n");
  740.         printf("int idx = 0 ;\n");
  741.         break;
  742.       case 'c':
  743.         printf("void sysroff_print_%s_out(ptr)\n",yyvsp[-1].s);
  744.         printf("struct IT_%s *ptr;\n", it);
  745.         printf("{\n");
  746.         printf("itheader(\"%s\", IT_%s_CODE);\n",yyvsp[-1].s,yyvsp[-1].s);
  747.         break;
  748.  
  749.       case 't':
  750.         break;
  751.       }
  752.  
  753.       ;
  754.     break;}
  755. case 6:
  756. #line 131 "./sysinfo.y"
  757. {
  758.   switch (writecode) {
  759.   case 'd': 
  760.     printf("};\n");
  761.     break;
  762.   case 'g':
  763.     printf("\tchecksum(file,raw, idx, IT_%s_CODE);\n", it);
  764.     
  765.   case 'i':
  766.  
  767.   case 'o':
  768.   case 'c':
  769.     printf("}\n");
  770.   }
  771. ;
  772.     break;}
  773. case 11:
  774. #line 158 "./sysinfo.y"
  775. {
  776.       rdepth++;
  777.       switch (writecode) 
  778.         {
  779.         case 'c':
  780.           if (rdepth==1)
  781.           printf("\tprintf(\"repeat %%d\\n\", %s);\n",yyvsp[0].s);
  782.           if (rdepth==2)
  783.           printf("\tprintf(\"repeat %%d\\n\", %s[n]);\n",yyvsp[0].s);
  784.         case 'i':
  785.         case 'g':
  786.         case 'o':
  787.  
  788.           if (rdepth==1) 
  789.         {
  790.           printf("\t{ int n; for (n = 0; n < %s; n++) {\n",    yyvsp[0].s);
  791.         }
  792.           if (rdepth == 2) {
  793.           printf("\t{ int m; for (m = 0; m < %s[n]; m++) {\n",    yyvsp[0].s);
  794.         }        
  795.  
  796.           break;
  797.         }
  798.  
  799.       oldrepeat = repeat;
  800.          repeat = yyvsp[0].s;
  801.     ;
  802.     break;}
  803. case 12:
  804. #line 188 "./sysinfo.y"
  805. {
  806.       repeat = oldrepeat;
  807.       oldrepeat =0;
  808.       rdepth--;
  809.       switch (writecode)
  810.         {
  811.         case 'i':
  812.         case 'g':
  813.         case 'o':
  814.         case 'c':
  815.       printf("\t}}\n");
  816.     }
  817.     ;
  818.     break;}
  819. case 13:
  820. #line 205 "./sysinfo.y"
  821. {
  822.       switch (writecode) 
  823.         {
  824.         case 'i':
  825.         case 'g':
  826.         case 'o':
  827.         case 'c':
  828.           printf("\tif (%s) {\n", yyvsp[0].s);
  829.           break;
  830.         }
  831.     ;
  832.     break;}
  833. case 14:
  834. #line 218 "./sysinfo.y"
  835. {
  836.       switch (writecode)
  837.         {
  838.         case 'i':
  839.         case 'g':
  840.         case 'o':
  841.         case 'c':
  842.       printf("\t}\n");
  843.     }
  844.     ;
  845.     break;}
  846. case 15:
  847. #line 232 "./sysinfo.y"
  848. {name = yyvsp[0].s; ;
  849.     break;}
  850. case 16:
  851. #line 234 "./sysinfo.y"
  852. {
  853.       char *desc = yyvsp[-8].s;
  854.       char *type = yyvsp[-6].s;
  855.       int size = yyvsp[-5].i;
  856.       char *id = yyvsp[-3].s;
  857. char *p = names[rdepth];
  858. char *ptr = pnames[rdepth];
  859.       switch (writecode) 
  860.         {
  861.         case 'g':
  862.           if (size % 8) 
  863.         {
  864.           
  865.           printf("\twriteBITS(ptr->%s%s,raw,&idx,%d);\n",
  866.              id,
  867.              names[rdepth], size);
  868.  
  869.         }
  870.           else {
  871.         printf("\twrite%s(ptr->%s%s,raw,&idx,%d,file);\n",
  872.                type,
  873.                id,
  874.                names[rdepth],size/8);
  875.         }
  876.           break;          
  877.         case 'i':
  878.           {
  879.  
  880.         if (rdepth >= 1)
  881.  
  882.           {
  883.             printf("if (!ptr->%s) ptr->%s = (%s*)xcalloc(%s, sizeof(ptr->%s[0]));\n", 
  884.                id, 
  885.                id,
  886.                type,
  887.                repeat,
  888.                id);
  889.           }
  890.  
  891.         if (rdepth == 2)
  892.           {
  893.             printf("if (!ptr->%s[n]) ptr->%s[n] = (%s**)calloc(%s[n], sizeof(ptr->%s[n][0]));\n", 
  894.                id, 
  895.                id,
  896.                type,
  897.                repeat,
  898.                id);
  899.           }
  900.  
  901.           }
  902.  
  903.           if (size % 8) 
  904.         {
  905.           printf("\tptr->%s%s = getBITS(raw,&idx, %d,size);\n",
  906.              id,
  907.              names[rdepth], 
  908.              size);
  909.         }
  910.           else {
  911.         printf("\tptr->%s%s = get%s(raw,&idx, %d,size);\n",
  912.                id,
  913.                names[rdepth],
  914.                type,
  915.                size/8);
  916.         }
  917.           break;
  918.         case 'o':
  919.           printf("\tput%s(raw,%d,%d,&idx,ptr->%s%s);\n", type,size/8,size%8,id,names[rdepth]);
  920.           break;
  921.         case 'd':
  922.           if (repeat) 
  923.         printf("\t/* repeat %s */\n", repeat);
  924.  
  925.           if (type[0] == 'I') {
  926.           printf("\tint %s%s; \t/* %s */\n",ptr,id, desc);
  927.         }
  928.           else if (type[0] =='C') {
  929.           printf("\tchar %s*%s;\t /* %s */\n",ptr,id, desc);
  930.         }
  931.           else {
  932.         printf("\tbarray %s%s;\t /* %s */\n",ptr,id, desc);
  933.           }
  934.           break;
  935.         case 'c':
  936.           printf("tabout();\n");
  937.           printf("\tprintf(\"/*%-30s*/ ptr->%s = \");\n", desc, id);
  938.  
  939.           if (type[0] == 'I')
  940.           printf("\tprintf(\"%%d\\n\",ptr->%s%s);\n", id,p);
  941.           else   if (type[0] == 'C')
  942.           printf("\tprintf(\"%%s\\n\",ptr->%s%s);\n", id,p);
  943.  
  944.           else   if (type[0] == 'B') 
  945.             {
  946.           printf("\tpbarray(&ptr->%s%s);\n", id,p);
  947.         }
  948.           else abort();
  949.           break;
  950.         }
  951.     ;
  952.     break;}
  953. case 17:
  954. #line 339 "./sysinfo.y"
  955. { yyval.s = yyvsp[0].s; ;
  956.     break;}
  957. case 18:
  958. #line 340 "./sysinfo.y"
  959. { yyval.s = "INT";;
  960.     break;}
  961. case 19:
  962. #line 345 "./sysinfo.y"
  963. { yyval.s = yyvsp[-1].s; ;
  964.     break;}
  965. case 20:
  966. #line 350 "./sysinfo.y"
  967. { yyval.i = yyvsp[-1].i * yyvsp[0].i; ;
  968.     break;}
  969. case 21:
  970. #line 355 "./sysinfo.y"
  971. { yyval.s = yyvsp[-1].s; ;
  972.     break;}
  973. case 22:
  974. #line 356 "./sysinfo.y"
  975. { yyval.s = "dummy";;
  976.     break;}
  977. case 26:
  978. #line 364 "./sysinfo.y"
  979.       switch (writecode) 
  980.         {
  981.         case 'd':
  982.           printf("#define %s %s\n", yyvsp[-2].s,yyvsp[-1].s);
  983.           break;
  984.         case 'c':
  985.         printf("if (ptr->%s%s == %s) { tabout(); printf(\"%s\\n\");}\n", name, names[rdepth],yyvsp[-1].s,yyvsp[-2].s);
  986.         }
  987.     ;
  988.     break;}
  989. case 27:
  990. #line 382 "./sysinfo.y"
  991. {
  992.       printf("Got %s\n", word);
  993.     ;
  994.     break;}
  995. }
  996.    /* the action file gets copied in in place of this dollarsign */
  997. #line 465 "/usr/unsupported/lib/bison.simple"
  998.  
  999.   yyvsp -= yylen;
  1000.   yyssp -= yylen;
  1001. #ifdef YYLSP_NEEDED
  1002.   yylsp -= yylen;
  1003. #endif
  1004.  
  1005. #if YYDEBUG != 0
  1006.   if (yydebug)
  1007.     {
  1008.       short *ssp1 = yyss - 1;
  1009.       fprintf (stderr, "state stack now");
  1010.       while (ssp1 != yyssp)
  1011.     fprintf (stderr, " %d", *++ssp1);
  1012.       fprintf (stderr, "\n");
  1013.     }
  1014. #endif
  1015.  
  1016.   *++yyvsp = yyval;
  1017.  
  1018. #ifdef YYLSP_NEEDED
  1019.   yylsp++;
  1020.   if (yylen == 0)
  1021.     {
  1022.       yylsp->first_line = yylloc.first_line;
  1023.       yylsp->first_column = yylloc.first_column;
  1024.       yylsp->last_line = (yylsp-1)->last_line;
  1025.       yylsp->last_column = (yylsp-1)->last_column;
  1026.       yylsp->text = 0;
  1027.     }
  1028.   else
  1029.     {
  1030.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1031.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1032.     }
  1033. #endif
  1034.  
  1035.   /* Now "shift" the result of the reduction.
  1036.      Determine what state that goes to,
  1037.      based on the state we popped back to
  1038.      and the rule number reduced by.  */
  1039.  
  1040.   yyn = yyr1[yyn];
  1041.  
  1042.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1043.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1044.     yystate = yytable[yystate];
  1045.   else
  1046.     yystate = yydefgoto[yyn - YYNTBASE];
  1047.  
  1048.   goto yynewstate;
  1049.  
  1050. yyerrlab:   /* here on detecting error */
  1051.  
  1052.   if (! yyerrstatus)
  1053.     /* If not already recovering from an error, report this error.  */
  1054.     {
  1055.       ++yynerrs;
  1056.  
  1057. #ifdef YYERROR_VERBOSE
  1058.       yyn = yypact[yystate];
  1059.  
  1060.       if (yyn > YYFLAG && yyn < YYLAST)
  1061.     {
  1062.       int size = 0;
  1063.       char *msg;
  1064.       int x, count;
  1065.  
  1066.       count = 0;
  1067.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  1068.       for (x = (yyn < 0 ? -yyn : 0);
  1069.            x < (sizeof(yytname) / sizeof(char *)); x++)
  1070.         if (yycheck[x + yyn] == x)
  1071.           size += strlen(yytname[x]) + 15, count++;
  1072.       msg = (char *) malloc(size + 15);
  1073.       if (msg != 0)
  1074.         {
  1075.           strcpy(msg, "parse error");
  1076.  
  1077.           if (count < 5)
  1078.         {
  1079.           count = 0;
  1080.           for (x = (yyn < 0 ? -yyn : 0);
  1081.                x < (sizeof(yytname) / sizeof(char *)); x++)
  1082.             if (yycheck[x + yyn] == x)
  1083.               {
  1084.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  1085.             strcat(msg, yytname[x]);
  1086.             strcat(msg, "'");
  1087.             count++;
  1088.               }
  1089.         }
  1090.           yyerror(msg);
  1091.           free(msg);
  1092.         }
  1093.       else
  1094.         yyerror ("parse error; also virtual memory exceeded");
  1095.     }
  1096.       else
  1097. #endif /* YYERROR_VERBOSE */
  1098.     yyerror("parse error");
  1099.     }
  1100.  
  1101.   goto yyerrlab1;
  1102. yyerrlab1:   /* here on error raised explicitly by an action */
  1103.  
  1104.   if (yyerrstatus == 3)
  1105.     {
  1106.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1107.  
  1108.       /* return failure if at end of input */
  1109.       if (yychar == YYEOF)
  1110.     YYABORT;
  1111.  
  1112. #if YYDEBUG != 0
  1113.       if (yydebug)
  1114.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1115. #endif
  1116.  
  1117.       yychar = YYEMPTY;
  1118.     }
  1119.  
  1120.   /* Else will try to reuse lookahead token
  1121.      after shifting the error token.  */
  1122.  
  1123.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1124.  
  1125.   goto yyerrhandle;
  1126.  
  1127. yyerrdefault:  /* current state does not do anything special for the error token. */
  1128.  
  1129. #if 0
  1130.   /* This is wrong; only states that explicitly want error tokens
  1131.      should shift them.  */
  1132.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1133.   if (yyn) goto yydefault;
  1134. #endif
  1135.  
  1136. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1137.  
  1138.   if (yyssp == yyss) YYABORT;
  1139.   yyvsp--;
  1140.   yystate = *--yyssp;
  1141. #ifdef YYLSP_NEEDED
  1142.   yylsp--;
  1143. #endif
  1144.  
  1145. #if YYDEBUG != 0
  1146.   if (yydebug)
  1147.     {
  1148.       short *ssp1 = yyss - 1;
  1149.       fprintf (stderr, "Error: state stack now");
  1150.       while (ssp1 != yyssp)
  1151.     fprintf (stderr, " %d", *++ssp1);
  1152.       fprintf (stderr, "\n");
  1153.     }
  1154. #endif
  1155.  
  1156. yyerrhandle:
  1157.  
  1158.   yyn = yypact[yystate];
  1159.   if (yyn == YYFLAG)
  1160.     goto yyerrdefault;
  1161.  
  1162.   yyn += YYTERROR;
  1163.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1164.     goto yyerrdefault;
  1165.  
  1166.   yyn = yytable[yyn];
  1167.   if (yyn < 0)
  1168.     {
  1169.       if (yyn == YYFLAG)
  1170.     goto yyerrpop;
  1171.       yyn = -yyn;
  1172.       goto yyreduce;
  1173.     }
  1174.   else if (yyn == 0)
  1175.     goto yyerrpop;
  1176.  
  1177.   if (yyn == YYFINAL)
  1178.     YYACCEPT;
  1179.  
  1180. #if YYDEBUG != 0
  1181.   if (yydebug)
  1182.     fprintf(stderr, "Shifting error token, ");
  1183. #endif
  1184.  
  1185.   *++yyvsp = yylval;
  1186. #ifdef YYLSP_NEEDED
  1187.   *++yylsp = yylloc;
  1188. #endif
  1189.  
  1190.   yystate = yyn;
  1191.   goto yynewstate;
  1192. }
  1193. #line 393 "./sysinfo.y"
  1194.  
  1195. /* four modes
  1196.  
  1197.    -d write structure defintions for sysroff in host format
  1198.    -i write functions to swap into sysroff format in
  1199.    -o write functions to swap into sysroff format out
  1200.    -c write code to print info in human form */
  1201.  
  1202. int yydebug;
  1203. char writecode;
  1204.  
  1205. int 
  1206. main(ac,av)
  1207. int ac;
  1208. char **av;
  1209. {
  1210.   yydebug=0;
  1211.   if (ac > 1)
  1212.     writecode = av[1][1];
  1213. if (writecode == 'd')
  1214.   {
  1215.     printf("typedef struct { unsigned char *data; int len; } barray; \n");
  1216.     printf("typedef  int INT;\n");
  1217.     printf("typedef  char * CHARS;\n");
  1218.  
  1219.   }
  1220.   yyparse();
  1221. return 0;
  1222. }
  1223.  
  1224. int yyerror()
  1225. {
  1226.   printf("Error twathead\n");
  1227. }
  1228.